﻿<cfsilent>
	<cfscript>
	
		event.setArg("pageTitle", "教学任务安排 - 计划任务合班");
		
		targetArgs = structNew();
		
		propAdvice = getProperty("serviceFactory").getBean("taskPropertyAdvice");
		
		termId = event.getArg("TermID");
		academicYear = event.getArg("AcademicYear");
		academicTerm = event.getArg("AcademicTerm");
		
		courseId = event.getArg("CID");
		teacherId = event.getArg("TCHID");
		teacherName = event.getArg('TNAME','未指定');

		sql = "SELECT 
					t_course.institute_id, 
					t_course.cid, 
					t_institute.institute_name, 
					t_course.course_credit, 
					t_course.course_name, 
					t_course.period, 
					t_course.period_theory, 
					t_course.period_week,
					t_course_prop.prop_name 
				FROM 
					t_course 
					INNER JOIN t_course_prop ON t_course_prop.prop_id = t_course.prop_id 
					INNER JOIN t_institute ON t_institute.institute_id = t_course.institute_id 
				WHERE 
					t_course.cid = :courseID ";
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="courseID", value=courseId, cfsqltype="cf_sql_varchar" );
		rs_courseEntity = queryObj.execute( sql=sql ).getResult(); 


		sql = "SELECT 
					t_task.tsk_id, 
					t_task.cidx, 
					t_teacher.tch_name, 
					t_task.task_week, 
					t_task.task_period, 
					t_task.task_limite, 
					t_task.task_classes, 
					t_campus.campus_name, 
					t_campus.campus_id, 
					t_task.task_prop 
				FROM 
					t_task 
					INNER JOIN t_teacher ON t_teacher.tch_id = t_task.tch_id 
					INNER JOIN t_campus ON t_campus.campus_id = t_task.campus_id 
				WHERE 
					t_task.term_id = :termId 
					AND 
					t_task.cid = :courseId 
				ORDER BY 
					t_task.cidx DESC ";
		queryObj = new query( datasource=application.dnsSlave );
		queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
		queryObj.addParam( name="courseId", value=courseId, cfsqltype="cf_sql_varchar" );
		rs_task = queryObj.execute( sql=sql ).getResult();
		
		
		sql = "SELECT cr_type, cr_type_name 
				FROM t_classroom_type  
				ORDER BY cr_type ";
		queryObj = new query( datasource=application.dnsSlave );
		rs_clsroomType = queryObj.execute( sql=sql ).getResult(); 

		sql = "SELECT campus_id, campus_name 
				FROM t_campus   
				ORDER BY campus_id ";
		queryObj = new query( datasource=application.dnsSlave );
		rs_campus = queryObj.execute( sql=sql ).getResult();
		
		currentTab = event.getArg("TabID", "labFormClass");
	
		
		rs_classOnTask = queryNew("cls_id");
		rs_taskEntity = queryNew("term_id");
		
		
		
		structInsert(targetArgs, "DepID", rs_courseEntity.institute_id);
		structInsert(targetArgs, "CID", rs_courseEntity.cid);
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('classMerge', targetArgs)#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">任课单位 <cfoutput>#rs_courseEntity.institute_name#</cfoutput></span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 course"></i>课程合班 《<cfoutput>#rs_courseEntity.course_name#</cfoutput>》
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labFormClass">class="active"</cfif> id="labFormClass" tabTarget="FormClass">未合班</span>
						<cfif rs_task.recordCount>
							<span <cfif currentTab eq "labTaskClass">class="active"</cfif> id="labTaskClass" tabTarget="TaskClass">教学任务列表</span>
						</cfif>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				<cfif rs_courseEntity.recordCount>
					<div class="noticeBlock">
						<h3>《<cfoutput>#rs_courseEntity.course_name#</cfoutput>》 任课单位: <cfoutput>#rs_courseEntity.institute_name#</cfoutput></h3>
						<p><span class="img icon16x16 message"></span>总学时 <em><cfoutput>#rs_courseEntity.period#</cfoutput></em>, 其中理论学时 <em><cfoutput>#rs_courseEntity.period_theory#</cfoutput></em>. 课程总学分:<em><cfoutput>#numberFormat(rs_courseEntity.course_credit, '_.00')#</cfoutput></em></p>
						<hr/>
					</div>
				</cfif>
				
				<div id="FormClass" class="tabContent">
					
					<div id="formBox" >
						
						<form id="formCreate" onSubmit="javascript:return processCreate();" class="formWrapper" method="post" action="<cfoutput>#buildURL('taskSpecialCreateDo')#</cfoutput>">
							
							<input type="hidden" name="CourseID" value="<cfoutput>#rs_courseEntity.cid#</cfoutput>" />
							<input type="hidden" name="TermID" value="<cfoutput>#termId#</cfoutput>" />
							<input type="hidden" id="TeacherID" name="TeacherID" value="<cfoutput>#teacherId#</cfoutput>" />
							
							<input type="hidden" id="ClassCampusID" name="ClassCampusID" value="" />
                                   
                                   
							<div class="label">
								<span class="req">*</span><b>计划人数</b>
								<input name="PlanSize" id="PlanSize" type="text" class="typeSmallInt" verification="integer" maxlength="5" value="20" /><span>计划实际执行人数 <strong id="classSizeReal"></strong></span>
								<p class="notice">教学班计划人数默认上浮15%, 用于重修、转专业及双学位等计划往外学生修读名额. </p>
							</div>
							
							<hr/>
						
							
							<div class="label">
								<b>上课校区</b>
                                        <p>望江校区<input name="CampusID" id="CampusID" type="hidden" value="<cfoutput>#rs_campus.campus_id#</cfoutput>" /></p>
							</div>
						
							
							<div class="label">
								<b>主讲教师</b>
								<input name="TeacherName" id="TeacherName" type="text" disabled="disabled" class="typeTextDynamic " verification="required" value="<cfoutput>#teacherName#</cfoutput>" /><span id="teacherTrigger" class="btnSearch"></span>
							</div>
							
							
							<hr/>
							
							<div class="lable">
								<input class="button" type="submit" value="建立教学班" />
							</div>
							
						</form>
						
						<script language="javascript" type="text/javascript">
							//<![CDATA[
							<!--
							
							function processCreate() {
								
								var teacherID = $("#TeacherID").val();
								
								if (teacherID != "") {
									
									return processVerfiyForm('formCreate');
									
								}
								else {
									alert("请先指定任课教师");
									
									$("#formBox").addClass("hidden_elem");
									$("#teacherBox").removeClass("hidden_elem");
									
									return false;
								}
								
							}
							
							$(document).ready(function() {
								
								$("#teacherTrigger").click(function(){

									$("#formBox").addClass("hidden_elem");
									$("#teacherBox").removeClass("hidden_elem");

								});
								
								$("#formReset").click(function(){
									
									$("#classBox").removeClass("hidden_elem");
									$("#formBox").addClass("hidden_elem");
									
								});
									
							});
							// -->
							//]]>
						</script>
						
					</div>
					
					<div id="teacherBox" class="hidden_elem">
						
						<form id="formSearch" class="formWrapper Transparent" method="post">
							<div class="label">
								<b>教师姓名或职工号</b>
								<input name="Keywords" id="Keywords" type="text" class="typeText" verification="required" maxlength="128" value="<cfoutput>#event.getArg('Keywords')#</cfoutput>" />
							</div>
							<hr/>
							<div class="lable">
								<input class="button1" type="submit" value="搜索教师" />
								<input id="formSearchReset" class="button" type="button" value="返回" />
							</div>
						</form>
						
						<div id="formSearchResult" class="UICardTable"></div>
						
						<script language="javascript" type="text/javascript">
							//<![CDATA[
							<!--
							$("input#formSearchReset").click(function(){
								
								$("#formBox").removeClass("hidden_elem");
								$("#teacherBox").addClass("hidden_elem");
								
							});
							
							$("#formSearch").submit(function(){
								
								if (processVerfiyForm('formSearch')) {
									
									$.getJSON(
											'<cfoutput>#buildURL("getTeacherByKeywords")#</cfoutput>',
											{
												'Keywords': $("form#formSearch input#Keywords").val(),
												'seed': (new Date()).getTime()
											},
											function(data) {
												
												$div = $("div#formSearchResult").html("").removeClass("hidden_elem");
												$("form#formAuth").addClass("hidden_elem");
												
												for (var i=0; i<data.length; i++) {
											
													var $element = $("<dl><dt><a><i class='sex" + data[i][2] + "'></i><dd><h3>" + data[i][1] + " [" + data[i][3] + "]" + "</h3><p>(" + data[i][0] + ")</p></dd></a></dt></dl>");
													
													$element
														.attr({
															'TeacherID' : data[i][0],
															'TeacherName' : data[i][1]
														})
														.click(function(){
															
															var name = $(this).attr('TeacherName');
															var id = $(this).attr('TeacherID');
															
															$("form#formCreate input#TeacherID").val(id);
															$("form#formCreate input#TeacherName").val(name + "(" + id + ")");
															
															/* backForm */
															$("#formBox").removeClass("hidden_elem");
															$("#teacherBox").addClass("hidden_elem");
																												
														})
														.appendTo($div);
													
												}
												
											});
								
								}
								
								return false;
							});
							
							// -->
							//]]>
						</script>
						
					</div>
                   </div>

				
				
				<div id="TaskClass" class="tabContent">
					
					<cfif rs_task.recordCount>
						<table id="taskClassList" class="UIEditable">
							<thead>
								<tr> 
									<td width="18"></td>
									<td >课序号</td>
									<td >教师</td>
									<td width="18"></td>
									<td width="18"></td>
								</tr>
							</thead>
							<tbody>
								 <cfloop query="rs_task">
                                         
									<cfset structInsert(targetArgs, "TaskID", rs_task.tsk_id, true) />
									<cfset propAdvice.parseProperty(rs_task.task_prop) />
									<tr class="editRows">
										<td><a href="<cfoutput>#buildURL('taskSpecialRemoveDo', targetArgs)#</cfoutput>" class="stat delete"></a></td>
										<td><span class="numeric"><cfoutput>#rs_task.cidx#</cfoutput></span></td>
										<td><cfoutput>#rs_task.tch_name#</cfoutput></td>
										
									</tr>
								</cfloop>
							</tbody>
						</table>	
					</cfif>
				</div>

		
			</div>
		</li>
	</ul>
</div>